home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 6 / The Arsenal Files 6 (Arsenal Computer).ISO / prg_casm / jlvesa11.zip / JLVESA17.ASM < prev    next >
Assembly Source File  |  1995-02-24  |  2KB  |  105 lines

  1. ; This file is part of JLVESA-library
  2. ;
  3. ; Copyright 1994 Johannes Lehtinen
  4. ; All rights reserved
  5.  
  6. model large,c
  7. p386
  8.  
  9. include "jlvesads.asm"
  10. extrn vesa_put_image_on:far
  11.  
  12. segment jlvesa17_TEXT USE16 'CODE'
  13. assume cs:jlvesa17_TEXT
  14.  
  15. ; void vesa_put_text_on(int x,int y,char *text,void *font)
  16. ;
  17. ; Outputs string. Font pointer should point to the start of
  18. ; font data.
  19. ;
  20. ;     Offset   Length   Function
  21. ;
  22. ;     0        512      Offset of data for characters 0-255
  23. ;
  24. ;     0        2        Width of character
  25. ;     2        2        Height of character
  26. ;     4        2        Difference in y-coordinate
  27. ;     6        2        Empty pixels before character
  28. ;     8        2        Empty pixels after character
  29. ;     10       ?        Character data
  30.  
  31. x_coord     dw    ?           ; X-coordinate
  32. y_coord     dw    ?           ; Y-coordinate
  33.  
  34. proc vesa_put_text_on far
  35.    public vesa_put_text_on
  36.  
  37.    push  bp
  38.    mov   bp,sp
  39.    push  si
  40.    push  di
  41.    push  ds
  42.    push  es
  43.  
  44.    ; Read address of font and address of string
  45.  
  46.    les   di,[ss:bp+14]
  47.    lds   si,[ss:bp+10]
  48.  
  49.    ; Read coordinates
  50.  
  51.    mov   ax,[ss:bp+6]         ; Read x-coordinate
  52.    mov   [cs:x_coord],ax
  53.    mov   ax,[ss:bp+8]         ; Read y-coordinate
  54.    mov   [cs:y_coord],ax
  55.  
  56.    ; Draw text one character at time
  57.  
  58. draw_loop:
  59.    mov   bp,[ds:si]           ; BP is next character
  60.    cmp   bp,0                 ; Check if end of string reached
  61.    je    short end_loop
  62.  
  63.    shl   bp,1                 ; Char data at ES:BP
  64.    mov   bp,[es:di+bp]
  65.    mov   ax,[es:di+bp]        ; AX is width of character
  66.    mov   bx,[es:di+bp+2]      ; BX is height of character
  67.    mov   cx,[cs:y_coord]      ; CX is y-coordinate
  68.    add   cx,[es:di+bp+4]
  69.    mov   dx,[es:di+bp+6]      ; DX is empty pixels before character
  70.    add   [cs:x_coord],dx
  71.    mov   dx,[es:di+bp+8]      ; DX is empty pixels after character
  72.    add   bp,di                ; BP is offset in ES
  73.    add   bp,10
  74.  
  75.    push  es                   ; Output character
  76.    push  bp
  77.    push  bx
  78.    push  ax
  79.    push  cx
  80.    push  [cs:x_coord]
  81.    add   [cs:x_coord],ax
  82.    add   [cs:x_coord],dx
  83.    call  far vesa_put_image_on
  84.  
  85.    inc   si
  86.    jmp   short draw_loop
  87.  
  88.    ; End drawing
  89.  
  90. end_loop:
  91.    pop   es
  92.    pop   ds
  93.    pop   di
  94.    pop   si
  95.    pop   bp
  96.    retf
  97.  
  98. endp vesa_put_text_on
  99.  
  100. ends
  101.  
  102. end
  103.  
  104.  
  105.